#pragma once

#include <Linker.h>

#include <fstream>

#include "../MCTypes.h"

typedef std::vector<std::string>
				DVtrLine;
typedef std::map<int, int>	DMapIndexs;

class CCsvFileLinker : public CLinker
{
public:
	CCsvFileLinker();
	~CCsvFileLinker();

public:
	bool			Connection(std::string strTarget);
	void			Disconnect();
	bool			IsConnection();

public:
	MCT::IDSet		ReadForm(MCT::DataForm dtForm);
//	MCT::DataIDs		ReadSelect(MCT::DataIDs dnForm, CDataSelect& dkWhere);
	bool			ReadData(MCT::IDInfo idiTarget, __out MCT::Data* pdOut);

private:
	bool			GetMovie(MCT::IDInfo idiTarget, __out MCT::Data* pdOut);
// 	bool			CheckMovie(SDataID dnID, CDataSelect& dsWhere);
// 	bool			Check(const std::string& strContent, CDataSelect& dsWhere, const std::string& strHearder);

	bool			ReadTitle();
	bool			ReadMark();
	bool			ReadMovie(MCT::IDInfo idiTarget, __out DVtrLine& vtrLine);

	void			DecodeLine(char* szLine, __out DVtrLine& vtrLine);

private:
	bool			m_isConnection;
	std::fstream		m_fsCsvFile;
	
	DVtrLine		m_vtrMovieTitles;
	DMapIndexs		m_mapMovieIndexs;
};
